package JavaBean;

public class one_deal {
	private int n1, n2, i1, i2;

	public one_deal() {
		super();
	}

	public one_deal(int n1, int n2, int i1, int i2) {
		super();
		this.n1 = n1;
		this.n2 = n2;
		this.i1 = i1;
		this.i2 = i2;
	}

	public int getN1() {
		return n1;
	}

	public void setN1(int n1) {
		this.n1 = n1;
	}

	public int getN2() {
		return n2;
	}

	public void setN2(int n2) {
		this.n2 = n2;
	}

	public int getI1() {
		return i1;
	}

	public void setI1(int i1) {
		this.i1 = i1;
	}

	public int getI2() {
		return i2;
	}

	public void setI2(int i2) {
		this.i2 = i2;
	}

	public String Addition() {
		int sum1 = n1 + n2;
		int sum2 = i1 + i2;
		String s1 = sum1==0 ? "" : sum1+"";
		String s2 = sum2==0 ? "" : sum2+"i";
		if(sum1==0&&sum2==0)
			return "0";
		if(sum1==0)
			return s2;
		if (sum2 > 0)
			return s1 + "+" + s2;
		else
			return s1 + "" + s2;
		
	}
	public String subtraction(){
		int sum1 = n1 - n2;
		int sum2 = i1 - i2;
		String s1 = sum1==0 ? "" : sum1+"";
		String s2 = sum2==0 ? "" : sum2+"i";
		if(sum1==0&&sum2==0)
			return "0";
		if(sum1==0)
			return s2;
		if (sum2 > 0)
			return s1 + "+" + s2;
		else
			return s1 + "" + s2;
		
	}
	public String multiplication(){
		int sum1 = n1*n2-i1*i2;
		int sum2 = n1*i2+n2*i1;
		String s1 = sum1==0 ? "" : sum1+"";
		String s2 = sum2==0 ? "" : sum2+"i";
		if(sum1==0&&sum2==0)
			return "0";
		if(sum1==0)
			return s2;
		if (sum2 > 0)
			return s1 + "+" + s2;
		else
			return s1 + "" + s2;
		
	}
	public String division(){
		int sum1 = (n1*n2+i1*i2);
		int sum2 = (i1*n2-n1*i2);
		String s1 = sum1==0 ? "" : sum1+"/"+(n2*n2+i2*i2);
		String s2 = sum2==0 ? "" : sum2+"/"+(n2*n2+i2*i2)+"i";
		if(sum1==0&&sum2==0)
			return "0";
		if(sum1==0)
			return s2;
		if (sum2 > 0)
			return s1 + "+" + s2;
		else
			return s1 + "" + s2;
		
	}
}
